/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var maximizeSum = function (nums, k) {
  let maxNum = nums[0]
  for (let i = 1; i < nums.length; i++) {
    if (nums[i] > maxNum) {
      maxNum = nums[i]
    }
  }
  let res = maxNum
  while (k > 1) {
    res += (maxNum + 1)
    maxNum++
    k--
  }
  return res
}
// 混积分的题，没意思
console.log(maximizeSum([1, 2, 3, 4, 5], 3))
console.log(maximizeSum([5, 5, 5], 2))